package dryven.view.engine.expression.nodetypes;

import java.util.Iterator;
import java.util.Map;

import dryven.codegen.asm.MethodBuilder;
import dryven.codegen.asm.TempValue;
import dryven.reflection.TypeRef;
import dryven.view.engine.expression.nodelisters.NodeLister;

public class MapLookupNode extends AbstractExpressionNode {

	private TypeRef _type;
	private String _name;
	
	public MapLookupNode(TypeRef type, String name, NodeLister lister) {
		super(lister);
		_type = type;
		_name = name;
	}
	
	@Override
	public TypeRef getComponentType() {
		return null;
	}

	@Override
	public String getName() {
		return _name;
	}

	@Override
	public Object evaluate(Object value) {
		Map map = (Map)value;
		return map.get(_name);
	}

	@Override
	public TempValue writeInstructions(MethodBuilder builder, TempValue value) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public TypeRef getType() {
		return _type;
	}

}
